package com.hontech.bread.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bread.R
import com.hontech.bread.device.mdb.Pos
import com.hontech.bread.ui.dialog.runProg
import com.hontech.bread.ui.view.LabelInput
import com.hontech.bread.utils.onClick
import com.hontech.bread.utils.stringById

class PosPayTestParts(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    private val liNum: LabelInput

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_pos_pay_test, this)
        liNum = view.findViewById(R.id.id_pos_pay_li_num)

        val payBtn = view.findViewById<Button>(R.id.id_pos_pay_btn_pay)
        payBtn.onClick { onClickPay() }
    }

    private suspend fun onClickPay() {
        runProg("POS", stringById(R.string.t1733460848_432)) {
            Pos.vendTest(liNum.textInt())
        }
    }
}